<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
	<title>goods_in_category</title>
	<link rel="stylesheet" type="text/css" href="./css/css_reset.css"/>
	<link rel="stylesheet" type="text/css" href="./css/goods_category.css"/>
	<script type="text/javascript" charset="utf-8" src="./js/jquery-1.11.3.min.js"></script>
</head>
<body>
	<div class="wrapper">
	<iframe src="./common/head.html"  frameborder="0" width="1260px" height="80px" scrolling="no" name="iframe3" ></iframe>
		<div class="list_container">
			<ul id="goods-container" class="goods-container">
				<li class="goods">
					<img src="" class="img">	
					<br/>	
					<span class="price"></span>
					<div class="goods-name"></div>
					<div style="color:#F7985D" class="desc"></div>
				</li>
				<li class="goods">
					<img src=""   class="img">	
					<br/>	
					<span class="price"></span>
					<div class="goods-name"></div>
					<div style="color:#F7985D" class="desc"></div>
				</li>
				<li class="goods">
					<img src="" class="img">	
					<br/>	
					<span class="price"></span>
					<div class="goods-name"></div>
					<div style="color:#F7985D" class="desc"></div>
				</li>
				<li class="goods">
					<img src="" class="img">	
					<br/>	
					<span class="price"></span>
					<div class="goods-name"></div>
					<div style="color:#F7985D" class="desc"></div>
				</li>
				<li class="goods">
					<img src="" class="img">	
					<br/>	
					<span class="price"></span>
					<div class="goods-name"></div>
					<div style="color:#F7985D" class="desc"></div>
				</li>
			</ul >
		</div>
		<iframe src="./common/foot.html" frameborder="0" width="1260px" height="370px" scrolling="no" name="frame2" ></iframe>
	</div>


	<script type="text/javascript">
	$(function(){
		function getvalue(name){
		    var str=window.location.search;   //location.search是从当前URL的?号开始的字符串
		    if (str.indexOf(name)!=-1){        
		        var pos_start=str.indexOf(name)+name.length+1;
		        var pos_end=str.indexOf("&",pos_start);
		        if (pos_end==-1){
		           return decodeURIComponent(str.substring(pos_start));
		        }else{
		            alert("没有此值~~");
		        }
		    }
		}
		var keyword = getvalue("keyword");
		var jsonData = {
			"keyword" : keyword
		}
		$.ajax({  
			type: "post",  
			url: "./handler/search.php",  
			dataType: "json", 
			contentType: "application/x-www-form-urlencoded; charset=utf-8", 
			data: jsonData,  
			success: function(msg){  
						for(var i = 0 ; i< msg.objectArray.length;i++){
							  $("#goods-container").children().eq(i).find('.price').html(msg.objectArray[i].Price);
							  $("#goods-container").children().eq(i).find('.goods-name').html(msg.objectArray[i].Course_Name);
							  $("#goods-container").children().eq(i).find('.desc').html(msg.objectArray[i].Course_Description);
							  var src = './src/commodity/'+msg.objectArray[i].img1;
							  $("#goods-container").children().eq(i).find('.img').attr('src',src);
						} 
				}  
		});
		$(".goods").click(function(){
			var keyword = $(this).find("img").attr("src");
			location.href="./goods_detail.html?keyword="+encodeURIComponent(keyword);
		})
	})
</script></body>   
</html>
